import axios from 'axios'
import { MessageBox, Message } from 'element-ui'
import store from '@/store/store.js'
import route from '@/router'
// create an axios instance
//刷新页面获取用户信息
window.onbeforeunload = function () {
    if (sessionStorage.getItem("userInfo")) {
        store.state.userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
    }
};
window.onbeforeunload()
//请求接口axios
const serviceapp = axios.create({
    // baseURL:"/api",
    baseURL: 'https://fishnovelapptest.yuwann.com/fishNovel', //测试App
    headers: {
        // 'Content-Type': 'application/x-www-form-urlencoded',
        // 'authorization': store.state.userInfo.token ? store.state.userInfo.token : '', //VueX
        'authorization': localStorage.getItem("token")
    },
    timeout: 5000 // request timeout
})
export default serviceapp